package com.amrit.threads;

import com.amrit.revision.MyCustomException;


public class MyAnotherThread extends Thread{

	private final int delay;
	public MyAnotherThread(String label, int d) {
		// Give this particular thread a
		//   name:  "thread 'LABEL'".
		super("thread '" + label + "'");
		delay = d;
	}
	@SuppressWarnings("static-access")
	public void run () {
		for (int count = 1, row = 1; row < 5; row++, count++) {
			try {
				System.out.format("Line #%d from %s\n", count, getName());
				Thread.currentThread().sleep(delay);
				//Thread.currentThread().wait();
			}
			catch (InterruptedException ie) {
				// This would be a surprise.
			}
		} throw new MyCustomException("This is surprise");
	}
}

